<!DOCTYPE html>
<html lang="zh-cn">
<head>
	<meta charset="UTF-8">
	<meta name='viewport' content='width=device-width,initial-scale=1,user-scalable=no'>
	<meta name='apple-mobile-web-app-capable' content='yes'/>
	<meta name='apple-mobile-web-app-status-bar-style' content='black'/>
	<meta name='format-detection' content='telephone=no,email=no,adress=no'/>
	<title><?=$sys['web_site_title'];?><?=isset($page_title)?'-'.$page_title:'';?></title>
    <meta name='keywords' content='<?=$sys['web_site_keywords'];?>'>
    <meta name='description' content='<?=$sys['web_site_description'];?>'>
	<meta name='viewport' content='width=device-width,initial-scale=1,user-scalable=no'>
	<meta name='apple-mobile-web-app-capable' content='yes'/>
	<meta name='apple-mobile-web-app-status-bar-style' content='black'/>
	<meta name='format-detection' content='telephone=no,email=no,adress=no'/>
	<link rel='stylesheet' type='text/css' href='/static/m/library/m.css?v=<?=env('version')?>'>
	<link rel='stylesheet' type='text/css' href='/static/m/library/lib.css?v=<?=env('version')?>'>
	<script src="https://cdn.bootcss.com/jquery/1.11.2/jquery.min.js?v=<?=env('version')?>"></script>
	<script type='text/javascript' src='/static/m/library/lib.js?v=<?=env('version')?>'></script>
	<script type='text/javascript' charset='UTF-8' src='/static/m/library/m.js?v=<?=env('version')?>'></script>
	<script type="text/javascript" src="/static/admin/common/layui/layui.js?v=<?=env('version')?>"></script>
	<script type="text/javascript" src="/static/vendor/function.js?v=<?=env('version')?>"></script>
</head>
<body>
	<div class='fixed hwrap'>
		<a href='/' target='_parent' class='rel'>
			<i class='icon-angle-left'></i>
		</a>
		<a href='javascript:;' target='_parent'></a>
		<h3 class='dyc'>忘记密码</h3>
	</div>
		<div style='height:45px;'></div>
		<form name="registerForm"  class="layui-form">
			<div class="aress_wrap">
			    <ul class="wrap">
			        <li class="notAll">
			            <input name="userphone" required lay-verify="required" type="text" placeholder="请输入手机号" maxlength="15" class="s_text">
			        </li>
			        <li class="notAll">
			            <input name="password" required lay-verify="required" type="password" placeholder="设置新密码" maxlength="20" class="s_text">
			        </li>
					<li class="notAll">
				    	<input name="code" type="text" required lay-verify="required" placeholder="图形验证码" class="s_text">
				        <span class="aress_btn" style="background:#fff;">
				            <img src='/publics/captcha.html' onclick="this.src='/publics/captcha?t='+Math.random()" id="ProveImg" style="margin-top:8px;">
				        </span>
				    </li>
			        <li class="notAll">
			            <input name="code" type="text" placeholder="请输入验证码" maxlength="10" class="s_text">
						<button type="button" class="aress_btn" lay-ignore style="background:#f2f2f2" onclick="sendsms(this,60,'forget')">获取验证码</button>
			        </li>
			    </ul>
			    <p class="help cF notAll">
			        <input name="agreement" type="checkbox" lay-ignore id="agreementId" class="form_checked" value="yes">
					用户<a target="_blank" href="/article/detail?id=3" class="aritc">《注册协议》</a></span>
			        <a href="/publics/login" class="fr">已有账户？</a>
			    </p>
				<input type="button" id="form_btn" lay-filter="myform" class="form_btn all_btn s_btn" style="background:#dddddd" value="立即注册">
			</div>
		</form>
	<script>
	$('[name="agreement"]').click(function(){
    	var obj = $("#form_btn");
    	if($(this).is(":checked")){
    		obj.css("background","#e4393c");
    		obj.attr("lay-submit","");
    	}else{
    		obj.css("background","#dddddd");
    		obj.removeAttr("lay-submit");
    	}
    });

	//发送短信
    function sendsms(e,second,type){
		var phone = $('[name="userphone"]').val();
  	  	var code = $("[name='code']").val();
  	  	var password = $("[name='password']").val();
        var reg = /^1[0-9]{10}$/;
        if(!reg.test(phone)){
            layer.msg('请填写正确的手机号');
  		  return false;
        }
        if(!code){
            layer.msg('请填填写图形验证码');
  		  return false;
        }
  	  if(!password || password.length<6){
  	  	layer.msg('密码长度至少6位数');
  	  	return false;
  	  }
      	$.ajax({
      		url:"<?=url('publics/sendSms');?>",
      		method:"post",
      		dataType:"json",
      		data:{phone:phone,type:type,code:code},
      		success:function(rs){
                  if(rs.code!=0){
                      layer.msg(rs.msg);
                      return false;
                  }
      			$(e).attr("disabled");
      			$(e).text("重新发送(" + second + ")");
                  var index = setInterval(function(rs) {
      				countdown = parseInt(/(\d+)/gi.exec($(e).text()));
      				if (countdown == 0) {
      	                $(e).removeAttr("disabled");
      	                $(e).text("获取验证码");
      					clearInterval(index);
      	                return false;
      	            } else {
      	                $(e).attr("disabled", true);
      	                countdown--;
      	                $(e).text("重新发送(" + countdown + ")");
      	            }
                  },1000);
      		}
      	});
      }
	</script>
</body>
</html>
